﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;


namespace CanvasEx.DrawCore
{
    class HotSpot : DrawObject
    {
        List<RectangleGeometry> rectlist = new List<RectangleGeometry>();
        List<Point> hotspotlist = new List<Point>();
        PathGeometry pathgeometry = new PathGeometry();

        public HotSpot(Painter p, DrawObject obj, double size)
            : base(p)
        {
            foreach (Point point in obj.GetHotSpot())
            {
                hotspotlist.Add(point);
                rectlist.Add(new RectangleGeometry(new Rect(point - new Vector(size, size), point + new Vector(size, size))));
                pathgeometry.AddGeometry(rectlist.Last());
            }
            
        }

        public override Geometry GetGeometry()
        {
            return pathgeometry;
        }
        public override bool InGraph(Point Location, double SelectAccuracy)
        {
            foreach (Point point in hotspotlist)
            {
                if (DrawHelper.Getdistance(Location, point) < SelectAccuracy)
                    return true;
            }
            return false;
        }
        public override List<Point> GetHotSpot()
        {
            return null;
        }

        public void SetSize(double size)
        {
            pathgeometry.Clear();
            for (int i = 0; i < rectlist.Count; i++)
            {
                rectlist[i].Rect = new Rect(hotspotlist[i] - new Vector(size, size),
                        hotspotlist[i] + new Vector(size, size));
                pathgeometry.AddGeometry(rectlist[i]);
            }
        }
    }
}
